<template>
	<view class="contain">
		<view class="topInfo">
			<view class="userImage">
				<navigator url="../changeUserInfo/changeUserInfo" class="login_user_image">
					<image v-if="userInfo" :src="userInfo.icon" mode="aspectFill"></image>
				</navigator>
			</view>
			<view class="user_info">
				<view class="login_user_info">
					<text class="nickname" v-if="userInfo">{{userInfo.nickname}}</text>
					<text v-else>Hi~</text>
					<text class="userName" v-if="userInfo">用户名：{{userInfo.username}}</text>
					<text v-else>您还没有登陆呢~</text>
				</view>
			</view>
		</view>
		<!-- 登陆、注册 -->
		<view class="login_btn_bar" v-if="!userInfo">
			<navigator class="regist" url="../login/register/register">
				注册
			</navigator>
			<navigator class="login" open-type="navigate" url="../login/login">
				登陆
			</navigator>
		</view>
		<!-- 我的订单 -->
		<view class="my_order">
			<text class="my_order_title">我的订单</text>
			<view class="order_btn_list">
				<navigator :url="'./orderProcess/orderProcess?type='+item.type" v-for="item in goodManage" :key="item.id">
					<image :src="'../../static/image/'+item.icon+'.png'" mode="widthFix"></image>
					<text>{{item.text}}</text>
				</navigator>

			</view>
		</view>
		<!-- 其他功能 -->
		<view class="somewhere_fn">
			<navigator class="somewhere_fn_item" :url="item.url?item.url:''" v-for="item in functionList" :key="item.id" @tap='callBtn(item)'>
				<image :src="item.icon" mode="widthFix"></image>
				<text>{{item.text}}</text>
			</navigator>
			<!-- 			<navigator url="./goodCollect/goodCollect" class="somewhere_fn_item">
			</navigator>
			<view class="somewhere_fn_item">
				<image src="../../static/image/brand.png" mode="widthFix"></image>
				<text>品牌</text>
			</view>
			<navigator url="./articleCollect/articleCollect" class="somewhere_fn_item">
				<image src="../../static/image/article.png" mode="widthFix"></image>
				<text>文章收藏</text>
			</navigator>
			<navigator class="somewhere_fn_item" url="./address/address">
				<image src="../../static/image/address.png" mode="widthFix"></image>
				<text>地址</text>
			</navigator>
			<view class="somewhere_fn_item">
				<image src="../../static/image/cart2.png" mode="widthFix"></image>
				<text>卡包</text>
			</view>
			<navigator url="cart/cart" class="somewhere_fn_item">
				<image src="../../static/image/cart2.png" mode="widthFix"></image>
				<text>购物车</text>
			</navigator>
			<view class="somewhere_fn_item" @tap='callBtn'>
				<image src="../../static/image/phone.png" mode="widthFix"></image>
				<text>联系我们</text>
			</view> -->
			<!-- flex布局占位 -->
			<view class="line"></view>
			<view class="line"></view>
		</view>
	</view>
</template>

<script>
	import checkUserLogin from '../../mixin/check_user_login.js';
	import request from '../../api/request.js';
	export default {
		data() {
			return {
				userInfo: null,
				// 商品管理
				goodManage: [{
					id: 0,
					text: '待付款',
					type: 'willpay',
					icon: 'icon-pay'
				}, {
					id: 1,
					text: '已付款',
					type: 'havepay',
					icon: 'pay-done'
				}, {
					id: 2,
					text: '已发货',
					type: 'shipments',
					icon: 'icon-car'
				}, {
					id: 3,
					text: '已收货',
					type: 'received',
					icon: 'icon-done'
				}, {
					id: 4,
					text: '售后',
					type: 'applicationDrawback',
					icon: 'icon-back'
				}],
				// 功能列表
				functionList: [{
						id: 1,
						text: '商品收藏',
						url: './goodCollect/goodCollect',
						icon: '../../static/image/save.png'
					},
					{
						id: 2,
						text: '品牌',
						icon: '../../static/image/brand.png'
					},
					{
						id: 3,
						text: '文章收藏',
						url: './articleCollect/articleCollect',
						icon: '../../static/image/article.png'
					},
					{
						id: 4,
						text: '地址',
						url: './address/address',
						icon: '../../static/image/address.png'
					},
					{
						id: 5,
						text: '卡包',
						icon: '../../static/image/cart2.png'
					},
					{
						id: 6,
						text: '购物车',
						url: './cart/cart',
						icon: '../../static/image/cart2.png'
					},
					{
						id: 7,
						text: '联系我们',
						icon: '../../static/image/phone.png'
					}
				]


			}
		},
		methods: {
			callBtn(item) {
				switch (item.id) {
					case 2:
					case 5:
						uni.showToast({
							title:`${item.text}功能未开发`,
							icon: 'none'
						})
					 break;
					case 7:
						uni.makePhoneCall({
							phoneNumber: '111'
						})
						break;
					default:
						break;
				}
			}
		},
		mixins: ["checkUserLogin"],
		async onShow() {
			const res = await checkUserLogin.checkUserLogin();
			if (res) {
				const userInfo1 = await request({
					url: '/login/getMemberInfo'
				})

				this.userInfo = userInfo1.data.data.userInfo;
			} else {
				this.userInfo = null
			}
		},
	}
</script>

<style lang="scss" scoped>
	@import "./mine.scss";
</style>
